package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.StrategyComment;
import cn.wolfcode.trip.base.query.StrategyCatalogQuery;
import cn.wolfcode.trip.base.service.IStrategyCommentService;
import cn.wolfcode.trip.base.util.JSONResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.wolfcode.trip.base.query.StrategyCatalogQuery;

/**
 * 添加后台的游记功能
 */
@Controller
@RequestMapping("strategyComment")
public class StrategyCommentController {

    @Autowired
    private IStrategyCommentService strategyCommentService;

    @RequestMapping("list")
    public String list(@ModelAttribute("qo") StrategyCatalogQuery qo, Model model) {
        PageInfo result = strategyCommentService.selectForList(qo);
        model.addAttribute("result", result);
        return "/strategycomment/list";
    }
    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyComment strategyComment) {
        JSONResult result = new JSONResult();
        try {
            strategyCommentService.update(strategyComment);
        } catch (Exception e) {
            result.mark(e.getMessage());
            e.printStackTrace();
        }
        return result;
    }
}
